import MyOrder from "@/pages/Center/MyOrder";
import GroupOrder from "@/pages/Center/GroupOrder";
export default [
  {
    name: "center",
    path: "/center",
    component: () => import("@/pages/Center"),
    meta: {
      show: true,
    },
    children: [
      {
        name: "myorder",
        path: "myorder",
        component: MyOrder,
      },
      {
        name: "grouporder",
        path: "grouporder",
        component: GroupOrder,
      },
      //重定向
      {
        path: "/center",
        redirect: "/center/myorder",
      },
    ],
  },
  {
    name: "paysuccess",
    path: "/paysuccess",
    component: () => import("@/pages/PaySuccess"),
    meta: {
      show: true,
    },
    beforeEnter: (to, from, next) => {
      if (from.path == "/pay") {
        next()
      } else {
        next(false)
      }
    }
  },
  {
    name: "pay",
    path: "/pay",
    component: () => import("@/pages/Pay"),
    meta: {
      show: true,
    },
    beforeEnter: (to, from, next) => {
      if (from.path == "/trade") {
        next()
      } else {
        next(false)
      }
    }
  },
  {
    name: "trade",
    path: "/trade",
    component: () => import("@/pages/Trade"),
    meta: {
      show: true,
    },
  },
  {
    name: "shopcart",
    path: "/shopcart",
    component: () => import("@/pages/ShopCart"),
    meta: {
      show: true,
    },
  },
  {
    name: "addcartsuccess",
    path: "/addcartsuccess",
    component: () => import("@/pages/AddCartSuccess"),
    meta: {
      show: true,
    },
  },
  {
    name: "detail",
    path: "/detail/:skuId?",
    component: () => import("@/pages/Detail"),
    meta: {
      show: true,
    },
  },
  {
    name: "test",
    path: "/test",
    component: () => import("@/pages/Test")
  },
  {
    name: "home",
    path: "/home",
    component: () => import("@/pages/Home"),
    meta: {
      show: true,
    },
  },
  {
    name: "search",
    path: "/search/:keyword?",
    component: () => import("@/pages/Search"),
    meta: {
      show: true,
    },
    //写法一 布尔值写法
    // props: true
    // 对象写法
    // props: {
    //   name: "xxx",
    //   age: 18
    // }
    // 函数写法
    props: ($route) => ({
      keyWord: $route.params.keyWord,
      k: $route.query.k,
    })
  },
  {
    name: "login",
    path: "/login",
    component: () => import("@/pages/Login"),
    meta: {
      show: false,
    },
  },
  {
    name: "registry",
    path: "/registry",
    component: () => import("@/pages/Registry"),
    meta: {
      show: false,
    },
  },
  {
    path: "*",
    redirect: "/home",
  },
];
